#include <iostream>
#include <string>
#include <vector>
using namespace std;
int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
}
int main() {
    int t;
    cin >> t;
    while(t--) {
        int n;
        cin >> n;
        vector<int> a;
        int k = 0;
        for(int i = 0; i < n; i++) {
            int temp;
            cin >> temp;
            if(i == 1) {
                k = temp;
            }
            a.push_back(temp);
        }
        int flag = 0;
        for(int i = 0; i < a.size(); i++) {
            if(i == 1) {
                continue;
            }
            int t = gcd(k, a[i]);
            k /= t;
            if(k == 1) {
                flag = 1;
                cout << "Yes" << endl;
                break;
            }
        }
        if(!flag)
        cout << "No" << endl;
    }
    return 0;
}